require "kuru_wrap.lua"
CommonNodeConfig = jsonContent

CommonNode = {}

function CommonNode:new(scene)
    instance = {}
    setmetatable(instance, self)
    self.__index = self

    instance.scene = scene
    instance.snap = instance:setSnapshot()
    instance.config = {}
    instance.makeup = instance:Initialize() or nil
    
    instance.nodes=instance:createNodes()
    instance.oldLipLayerBlendModes = {nil, nil, nil}
    instance.lipLayers = {nil, nil, nil}
   
    instance.sampler = instance:createSampler()
    instance.configNum = instance:getconfigNum()

    return instance
end
-- function CommonNode:reBuildLipLayers(scene)

-- end
function CommonNode:Initialize()

end
function CommonNode:FrameReady(elapsedTime)

end
function CommonNode:createNodes()
    self.config = CommonNodeConfig
    g_nodes = {}
    for i = 1, #self.config do
        g_nodes[i] = KuruWrap.addNodeWithConfig(self.scene, self.config[i])
    end
    return g_nodes
end

function CommonNode:getNodes()
    return self.nodes
end

function CommonNode:getconfigNum()
    return #self.config
end

function CommonNode:getSampler()
    return self.sampler
end

function CommonNode:createSampler()
    node = KuruSnapshotNode.create()
    self.scene:addNode(node)
    node:release()
    return node:getSnapshot()
end

function CommonNode:setSnapshot()
    node = KuruSnapshotNode.create()
    self.scene:addNode(node)
    node:release()
    return node
end
function CommonNode:Clear()
    passThroughNode = KuruShaderFilterNode.createWithFragmentShaderFile(BASE_DIRECTORY .. "passthrough.frag", true)
    self.scene:addNodeAndRelease(passThroughNode)
    passThroughNode:setChannel0(self.snap:getSnapshot())
end
